import torch

a = torch.Tensor([[1,2],[3,4]])#直接输入数组进行创建
print(a)
print(a.type())#float类型

a = torch.zeros((2,3))#全 0 的张量
print(a)

a = torch.Tensor(2,3)
print(a)

a = torch.ones(2,3)
print(a)

a = torch.eye(3)#对角矩阵,对角线为 1
print(a)
print(a.type())

a = torch.arange(0,10,2)#等差数组,区间为[a,b)
print(a)

a =torch.rand((2,3))#均匀分布
print(a)

a = torch.randn((2,3))#正太分布
print(a)
print("Shape:", a.shape)  # 获取形状
print("Device:", a.device)  # 设备